β¨ This blog post was created with AI assistance to help developers understand Uniface better.
π What is a Server Shell?
A server shell is a special component in Uniface that defines how an application server behaves. The application server is responsible for executing remote components like server pages and services. Think of it as the "brain" π§ that controls how your server-side applications work.
π― Why Do You Need Server Shells?
Uniface provides a default application server called the Uniface Server (userver.aps). This default server gives you generic functionality for executing components, accessing files, and working with databases. However, there are times when you need more control over your server's behavior.
You might want to create your own server shell when you need:
- π Custom authentication routines for web applications
- βοΈ Special batch processing logic
- π‘οΈ Customized security checks
- π Unique logging or monitoring features
ποΈ What Makes Up a Server Shell?
A server shell consists of two main components:
- Application Triggers π¬ - These are special event handlers that run at specific times
- A Library π - This contains the compiled code and resources
Unlike other application types, server shells don't have server-specific properties. They're designed to be lightweight and focused.
π‘ Practical Example: Custom Authentication
Let's say you want to check usernames and passwords before allowing access to your server pages. Here's how you could do it:
Step 1: Define your custom application shell (let's call it "webasv")
Step 2: Add authentication logic in the preRequest trigger:
if($user != "correct-user" | $password != "correct-password")
return (-21)
endif
This simple code checks if the username and password match your requirements. If they don't match, it returns an error code (-21) and blocks access. π«
Step 3: Compile your application shell and add it to your UAR (Uniface Application Resource) file.
Step 4: Update your Uniface Router configuration to use your new server shell:
wasv = "C:\Uniface\bin\userver.exe webasv.aps" /dir="C:\project"
β οΈ Important Notes
File Extension Matters! π When you specify a server shell on the ide.exe command line, you must include the .aps extension. However, this extension is not required when using the uniface.exe command line.
Example:
- With ide.exe:
myshell.aps
β - With uniface.exe:
myshell
β
π How It Works in Real Applications
When a user tries to access a server page:
- The Uniface Router receives the request π¨
- It starts a Uniface Server process using your custom shell π§
- Your application triggers (like preRequest) execute first π¬
- If everything passes, the requested component loads and runs β
- Results are sent back to the user π€
π Key Takeaways
Server shells in Uniface 10.4 give you the power to customize server behavior without changing the core Uniface Server. They're perfect for adding authentication, custom logging, batch processing, or any other server-side logic your application needs. πͺ
By understanding server shells, you can build more secure and efficient Uniface applications that meet your specific business requirements. Whether you're building web applications, APIs, or batch processing systems, custom server shells give you the flexibility you need.
Happy coding! π¨βπ»π©βπ»
Top comments (0)